# This is a sample Python script.
import math

from Loophole import Loophole
from Properties import Properties
import pandas as pd


# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

# Press the green button in the gutter to run the script.

def get_loopholes(file_name):
    loopholes = []
    file = pd.read_csv(file_name)
    total = len(file)

    for row in range(0, total):
        loophole = Loophole()
        for name, member in Properties.__members__.items():
            value = file.iloc[row, member.value]
            if isinstance(value, float) and math.isnan(value):
                value = "none"
            loophole.add_property(name, value)
        loopholes.append(loophole)

    return loopholes


if __name__ == '__main__':
    file_name = '212e0765-c428-4de2-b85c-4e9f6986ecf0.csv'
    loopholes = get_loopholes(file_name)

    # example
    # for loophole in loopholes:
    #     print(loophole.get_property(Properties.NVT_name))

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
